<extend name='./Public/Base/admin_base.html' />
<block name='script'>
	<link rel="stylesheet" href="__PUBLIC__/Admin/service_list.css"> 
</block>
<block name='content'>

<div class='container-layout'>
	<div class='line margin'>
		<div class='x9'>首页 / 项目管理 / 条件管理</div>
	</div>
	<hr>

	<div class='line margin'>
		<h3>服务选择</h3>
		<div class='x3'>
			<select class='input' id='ServiceList'>
				<volist name='res_Type' id='vo' >
					<option value='{$vo.type_id}'>{$vo.type_name}</option>
				</volist>
			</select>
		</div>
		<div class='x3 x6-move'>
			<button class='button bg-sub' id='CondLv1Add'>新增一级条件</button>
		</div>
		<div class='x8 x1-move hidden' id='CondLv1AddArea'>
			<form action='service_cond_lv1_sub' method='post'>
				<div class='x5'>
					<div class='x6'><input type='text' name='name'  class='input' placeholder='输入条件名' /></div>
					<div class='x6'><input type='text' name='name_form'  class='input' placeholder='输入表单项名' /></div>
					<input type='hidden' name='token'  value='<?php echo Token_Set('service_cond_sub_lv1');?>' />
					<input type='hidden' class='service_id' name='service_id' />
				</div>
				<div class='x2 x1-move'>
					<input type='submit' class='button bg-green' value='添加' />
				</div>
			</form>
		</div>
	</div>
	
	<div class='line margin'>
		<div class='x12'><h2>条件列表：</h2></div>
		<hr>
		<div class='x12'  id='service_cond_list'></div>
	</div>

</div>





</block>
<block name='bottom'>
<script>
	$(function(){




		//服务选择，设置一级条件关联的服务id
		if(sessionStorage.ServiceId){
			$('#ServiceList').find('option').each(function(){
				if($(this).val() == sessionStorage.ServiceId){
					$(this).attr('selected',true);
				}
			});
		}else{
			sessionStorage.ServiceId = $('#ServiceList').find('option:selected').val();
		}
		$('#ServiceList').change(function(){
			sessionStorage.ServiceId = $('#ServiceList').find('option:selected').val();
			SetServiceId();
			get_service_cond_list();
		});
		SetServiceId();

		get_service_cond_list();
		//异步加载条件列表
		function get_service_cond_list(){
			$.ajax({
				url:'service_cond_list',
				data:{
					sid:sessionStorage.ServiceId
				},
				success:function(res){
					$('#service_cond_list').html(res);
				}
			});
		}

		
		$('#CondLv1Add').click(function(){
			$(this).addClass('hidden');
			$('#CondLv1AddArea').removeClass('hidden')
		});
	});
	function SetServiceId(){
		$('.service_id').val(sessionStorage.ServiceId);
	}
</script>
</block>